<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <button id="btn">点击登录</button>
    <ul>
        <li>1</li>
        <li>2</li>
        <li>3</li>
        <li>4</li>
        <li>5</li>
        <li>6</li>
    </ul>
    <input type="text" id="kbd">
    <script>
        var btn = document.getElementById('btn')
        var lis = document.getElementsByTagName('li')
            // 点击事件  click   on是注册事件的关键字
        btn.onclick = function() {
            alert('青春不常在，抓紧谈恋爱')
        }
        for (var i = 0; i < lis.length; i++) {
            // console.log(lis[i])
            // 鼠标移入事件 没有冒泡
            lis[i].onmouseenter = function() {
                    // lis[i].style.background = 'red'
                    // console.log(lis[i])
                    this.style.background = 'red'
                }
                // 鼠标移出事件
            lis[i].onmouseleave = function() {
                this.style.background = ''
            }
        }
        var kbd = document.getElementById('kbd')
            // kbd.onkeydown = function() {
            //         console.log(this.value)
            //     }
        kbd.onkeypress = function() {
                console.log(this.value)
            }
            // kbd.onkeyup = function() {
            //     console.log(this.value)
            // }
    </script>
</body>

</html>